<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>for in and in</title>
</head>
<body>
    <script>
        
        {


            let obj = {
                name: 'ws',
                age: 27,
                gender: 0,
                from: 'hn'
            };

            for (const key in obj) {
                if (obj.hasOwnProperty(key)) {
                    const element = obj[key];
                    console.log(element);
                }
            }


            // 如果指定的属性在指定的对象或其原型链中，则in 运算符返回true

            let ary = ["11","22","33","44","55"];

            for (const key in ary) {
                if (ary.hasOwnProperty(key)) {
                    const element = ary[key];
                    console.log(element);
                    console.log('ary',key);
                }
            }

            console.log(4 in ary);
            console.log('44' in ary);

        }
    
    </script>
</body>
</html>